<!DOCTYPE HTML>
<html>
<head>
	<title>我的个人博客</title>
	<meta charset="utf8">
	<link rel="stylesheet" type="text/css" href="style.css">
	<link rel="icon" type="image/png" href="simbs.png">
</head>
<body>

<div class="top">
	<div class="header"> 
                <div class="logo">
                        <a href="index.php"><img src="logo.png"/></a>
                </div>
		<div id="container">
			<ul>
<?php
	//调用文件CatalogService.class.php
	require_once 'CatalogService.class.php';
	$catalogService = new CatalogService();
	echo $catalogService->navigation();
?>
			</ul>
		</div>
	</div>
	<div class="single">
<?php

	//调用pager.class.php.BlogService.class.php
	require_once 'BlogService.class.php';
	require_once 'pager.class.php';
	
	$pager = new pager();

	//设置页码
	if(!empty($_GET['pageNow'])){
		$pager->pageNow = $_GET['pageNow'];
	}else{
		$pager->pageNow = 1;
	}
	
	$pager->pageSize = 6;
	
	//创建blogService对象
	$blogService = new BlogService();
	//如果接受到$_GET['trashed']='1'以及$_GET['id'],则删掉那个id的文章
	 if(!empty($_GET['trashed'])){
		$id = $_GET['id'];
		$blogService->trashedBlog($id);	
	}

	$blogService->getPager($pager);
	for($i=0;$i<count($pager->res_array);$i++){
		$row = $pager->res_array[$i];
		$id = $row['id'];
		echo "<div id='title'><a href='blogPage.php?id=$id'><h2>{$row['title']}</h2></a></div>";
		echo "<div id='content'><a href='blogPage.php?id=$id'><p>{$row['content']}</p></a></div>";	
	}
	
	
	//显示分页下的导航栏
	echo $pager->navend;
?>
	</div>
	<div class="sidebar">
		<div class="login">
		<form action="loginProcess.php" method="post">
<?php
	function getCookie($key){
		if(empty($_COOKIE["$key"])){
			return "";
		}else{
			return $_COOKIE["$key"];
		}
	}
?>
			用户id<input type="id" name="id" value="<?php echo getCookie('id');?>"/>
			密码&nbsp;&nbsp;&nbsp;<input type="password" name="password" value="<?php echo getCookie('password');?>"/>
			<input type="checkbox" name="SaveCookie">两周内自动登录
			<input type="submit" value="用户登录"/>
			<input type="reset" value="重新填写"/><br />
		<?php
			//接受erro
			if(!empty($_GET['errno'])){
				$errno=$_GET['errno'];
				if($errno==1){
					echo "你的用户名或者密码错误";
				}
			} 
		?>

		</form>
		</div>
		<div class="latest">最近更新
		<ul>
<?php
	//调用文件BlogService.php
	require_once 'BlogService.class.php';
	$blogService = new BlogService();
	echo $blogService->getLatestBlogTitle(10);
?>
		</ul>
		</div>
	</div>
	<div id="footer">
		<p>Copyright &#169;2012 Powered by <a href="http://code.google.com/p/simbs/">simbs</a> </p>
	</div>
</div>
</body>
</html>
